package io.jsen.meta.diff.feature;

import com.google.common.collect.Maps;

import java.util.Map;

/**
 * 字段特性，比如某个字段需要使用特殊的index，则可以定义IndexFeature，
 * <p>
 * 然后再这个字段上使用MetaFieldFeature注解，加上这个IndexFeature的实现类
 *
 * @author jsen
 * @date 2021/4/8
 */
public class MetaFeatureContext {
    private static final Map<Class<?>, Feature> FEATURE_MAP = Maps.newHashMap();

    public static void register(Feature feature) {
        FEATURE_MAP.put(feature.getClass(), feature);
    }

    @SuppressWarnings("unchecked")
    public static <T extends Feature> T get(Class<?> clazz) {
        return (T) FEATURE_MAP.get(clazz);
    }

    private MetaFeatureContext() {
    }
}
